# 计算非个位数的火柴棍个数：
def match_num(num):
    num_match = 0
    # 判断是否是个位数
    while num/10 >= 1:
        last = num % 10
        num = int(num / 10)
        num_match += num_dict[last]
    num_match += num_dict[num]
    return num_match

# 数字字典，键为表示的具体值，值是需要的火柴棍个数
num_dict = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
# 火柴棍个数
match = 22
# m表示火柴棍能够组成的最大数
m = 1111

for i in range(m):
    i_num = match_num(i)
    for j in range(m):
        j_num = match_num(j)
        k = i + j
        k_num = match_num(k)
        if k_num + i_num + j_num == match - 4:
            print('%d + %d = %d' % (i, j, k))
